#pragma once
#include "EventsSink.h"
#include <ocidl.h>
#include <atlbase.h>
#include <AtlWin.h>
#include <exdisp.h>
#include <mshtml.h>
#include <atltypes.h>


//typedef CWinTraits<WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> CWebWinTraits;
class CWebPage // : public CWindowImpl<CWebPage, CWindow, CWebWinTraits>
{
public:
	CWebPage(void);
	~CWebPage(void);
	
	bool		CreateWebBrowser(HWND hWndParent, int id, RECT *pRectInClient = NULL);
	bool		CloseWebBrowser();
	bool		ShowWebPage(bool bShow);
	bool		ResizeWebPage(CSize szNew, CPoint ptLeftTop);

	HWND		GetWebPageHWND(){return m_hWndWeb;}
	void		SetDataInt(int data){m_data = data;}
	void		SetDataVoid(void* pVoid){m_pVoid = pVoid;}
	int			GetDataInt(){return m_data;}
	void*		GetDataPvoid(){return m_pVoid;}

	bool		SetTitle(BSTR pszTitle);	
	bool		Navigate(LPCTSTR pszUrl);
	void        OnDocumentComplete();
	void		OnHtmlWindowScroll();

	IHTMLDocument2* GetHtmlDocument(void);
	IHTMLWindow2*	GetHtmlWindow(void);
	IDispatch*		GetWebDisptch(void);

private:
	bool		SetHtmlWindowStyle();

private:
	int				m_id;
	HWND			m_hWndWeb;
	CAxWindow		m_axWindow;

	IWebBrowser2	*m_pWebBrowser2;
	IDispatch		*m_dispWebBrowser2;
	IHTMLWindow2    *m_pHtmlWin2;
	IHTMLDocument2  *m_pHtmlDoc2;
	IHTMLDocument3  *m_pHtmlDoc3;

	void			*m_pVoid;
	int				m_data;
};
